<?php
//提交数据进行注册
require "model/usersreg.php";
class RegsubmitController{
    function submit(){
        $db=new mydb();
        $usersid=new users();
        $name=$_GET['username'];
        $password=$_GET['password'];
        $rand=rand(1000,9999);
        $password=md5($password.$rand);
        $sql = "select id from usersreg WHERE username='$name'";
        $obj=$db->doquery($sql);
        if(count($obj)!=0){
            echo 0;
            exit;
        }else{
            echo 1;
            $sql1="insert into usersreg(username,password,rand) VALUES ('$name','$password','$rand')";
            $db->doadd($sql1);
            $sql = "select id from usersreg WHERE username='$name'";
            $obj=$db->doquery($sql);
            $id=$usersid->getid($obj);
            $sql2="insert into usersinfo(uid,username) VALUES ('$id','$name')";
            $db->doadd($sql2);
        }
    }
}
?>